﻿<ResourceDictionary 
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:v="clr-namespace:ShredTheLog.Views;assembly=ShredTheLog.Views"
    xmlns:vm="clr-namespace:ShredTheLog.ViewModels;assembly=ShredTheLog.ViewModels"
    xmlns:cnv="clr-namespace:ShredTheLog.Converters;assembly=ShredTheLog.Converters"
    xmlns:c="clr-namespace:ShredTheLog.Controls;assembly=ShredTheLog.Controls"
    xmlns:tk="clr-namespace:Microsoft.Windows.Controls;assembly=WPFToolkit"
    >

    <DataTemplate DataType="{x:Type vm:UserSearchConditionsViewModel}">
        <StackPanel Orientation="Vertical" HorizontalAlignment="Stretch">
            <Grid>
                <Panel.Resources>
                    <Style x:Key="FieldLabelStyle" TargetType="{x:Type Label}">
                        <Setter Property="HorizontalAlignment" Value="Right"/>
                    </Style>
                    
                    <DataTemplate DataType="{x:Type cnv:NullValue}">
                        <TextBlock/>
                    </DataTemplate>
                </Panel.Resources>

                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>

                <Label Grid.Row="0" Grid.Column="0" Content="{c:LocalizedString s_NativeLanguage}" Style="{StaticResource FieldLabelStyle}"/>
                <ComboBox Grid.Row="0" Grid.Column="1" ItemsSource="{cnv:LanguageList AllowNull=True}" SelectedItem="{Binding Path=KnownLanguage, Mode=TwoWay, Converter={x:Static cnv:NullableLanguageConverter.Default}}"/>

                <Label Grid.Row="1" Grid.Column="0" Content="{c:LocalizedString s_PracticingLanguage}" Style="{StaticResource FieldLabelStyle}"/>
                <ComboBox Grid.Row="1" Grid.Column="1" ItemsSource="{cnv:LanguageList AllowNull=True}" SelectedItem="{Binding Path=PracticingLanguage, Mode=TwoWay, Converter={x:Static cnv:NullableLanguageConverter.Default}}"/>

                <Label Grid.Row="2" Grid.Column="0" Content="{c:LocalizedString s_SeekingAChatExchange}" Style="{StaticResource FieldLabelStyle}"/>
                <ComboBox Grid.Row="2" Grid.Column="1" ItemsSource="{cnv:YesNoList AllowNull=True}" SelectedItem="{Binding Path=ChatsOnline, Mode=TwoWay, Converter={x:Static cnv:NullableBoolConverter.Default}}" HorizontalAlignment="Left" Width="50"/>

                <Label Grid.Row="3" Grid.Column="0" Content="{c:LocalizedString s_FirstName}" Style="{StaticResource FieldLabelStyle}"/>
                <TextBox Grid.Row="3" Grid.Column="1" Text="{Binding Path=FirstName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>

                <Label Grid.Row="4" Grid.Column="0" Content="{c:LocalizedString s_LastName}" Style="{StaticResource FieldLabelStyle}"/>
                <TextBox Grid.Row="4" Grid.Column="1" Text="{Binding Path=LastName, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>

                <Label Grid.Row="5" Grid.Column="0" Content="{c:LocalizedString s_Age}" Style="{StaticResource FieldLabelStyle}"/>
                <StackPanel Grid.Row="5" Grid.Column="1" Orientation="Horizontal">
                    <Label Content="{c:LocalizedString s_From}"/>
                    <TextBox Text="{Binding Path=MinAge, Mode=TwoWay, Converter={x:Static cnv:NullableIntConverter.Default}, UpdateSourceTrigger=PropertyChanged}" MaxLength="3" Width="30"/>
                    <Label Content="{c:LocalizedString s_To}"/>
                    <TextBox Text="{Binding Path=MaxAge, Mode=TwoWay, Converter={x:Static cnv:NullableIntConverter.Default}, UpdateSourceTrigger=PropertyChanged}" MaxLength="3" Width="30"/>
                </StackPanel>

                <Label Grid.Row="6" Grid.Column="0" Content="{c:LocalizedString s_Country}" Style="{StaticResource FieldLabelStyle}"/>
                <ComboBox Grid.Row="6" Grid.Column="1" ItemsSource="{cnv:CountryList AllowNull=True}" SelectedItem="{Binding Path=Country, Mode=TwoWay, Converter={x:Static cnv:NullableCountryConverter.Default}}"/>

                <Label Grid.Row="7" Grid.Column="0" Content="{c:LocalizedString s_City}" Style="{StaticResource FieldLabelStyle}"/>
                <TextBox Grid.Row="7" Grid.Column="1" Text="{Binding Path=Location, Mode=TwoWay}"/>

            </Grid>
            <Button Content="{c:LocalizedString s_SearchNow}" IsDefault="True" Command="{Binding OkCommand}" Width="Auto" HorizontalAlignment="Center" MinWidth="{x:Static c:UX.ButtonWidth}"/>
        </StackPanel>
    </DataTemplate>
</ResourceDictionary>